package com.flower.controller;

import com.flower.pojo.Address;
import com.flower.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private AddressService addressService;

    @RequestMapping("/address_add")
    public Map<String, Object> addressAdd(Address address, HttpSession session) {
        Map<String, Object> map = new HashMap<>();
//        int uid = (Integer) session.getAttribute("uid");
            address.setUid(1);
        System.out.println(address);
        int result = addressService.addressAdd(address);
        if (result != -1) {
            map.put("code", 200);
            map.put("msg", "用户地址添加成功");
        } else {
            map.put("code", 201);
            map.put("msg", "用户地址添加失败");
        }
        return map;
    }
}

